import request from '../utils/request.js';

//  获取文章
export const postArticlei = (url, page, count) => {
  return request({
    method: 'post',
    url: url,
    data: { pageNum: page, pageSize: count },
  });
};
//  最新文章
export const postNewArticle = (page, count) => {
  return request({
    method: 'post',
    url: '/es/newestArticle',
    data: { pageNum: page, pageSize: count },
  });
};

//  根据 id 查询 文章详情
export const postArtDetails = id => {
  return request({
    method: 'post',
    url: `/es/findByIdArticle/${id}`,
  });
};

// 上传图片
export const richTextImgUpload = formData => {
  return request({
    method: 'post',
    url: '/upload/upload',
    data: { img: formData },
  });
};

// 文章点赞
export const likeArticle = obj => {
  return request({
    method: 'post',
    url: '/es/articleLikes',
    Authorization:
      'eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NDI1MTMxODUsInVzZXJJZCI6MTQwNDQ0ODU4ODE0NjE5MjM5NiwiaWF0IjoxNjQxNjI0MTUyfQ.f1dr3i_BdaLuI5WAs17UECOzz4aUQoolsF26VNCUXa4',
    data: {
      articleId: 'uxnqNH4BnMkda92A934l',
      whetherAttention: true,
    },
  });
};
